<template>
  <div class="dashboard-editor-container">
    <div ref="vantaRef" style="width: 100%; height: 100%;"></div>
    <div class="dashboard-editor-container-text">
      <span>欢迎您，{{ userInfo.userName }}</span>
      <div class="small">
        <div>系统简介：</div>
        <div v-html="form.remark"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import * as THREE from 'three'
import WAVES from 'vanta/src/vanta.waves'
import { getNoticeList } from "@/views/noticeList/api";

export default {
  name: "DashboardAdmin",
  computed: {
    ...mapGetters([
      'userInfo',
    ])
  },
  data () {
    return {
      form: {}
    }
  },
  created () {
    this.getIntroduce()
  },
  mounted () {
    this.vantaEffect = WAVES({
      el: this.$refs.vantaRef,
      THREE: THREE,
      shininess: 30,
      waveHeight: 15,
      waveSpeed: 1,
      zoom: 1,
      mouseControls: true,
      color: 'rgb(0, 85, 136)',
      scale: 1.00,
      scaleMobile: 1.00
    })
  },
  beforeDestroy () {
    if (this.vantaEffect) {
      this.vantaEffect.destroy()
    }
  },
  methods: {
    getIntroduce () {
      getNoticeList()
          .then((res) => {
            if (!res) return
            const { data } = res
            this.loading = false
            this.form = { ...data[0] }
          })
          .catch((err) => {
            console.log('TCL: getTableData -> err', err)
          })
    }
  }
};
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  background-color: rgb(240, 242, 245);
  position: relative;
  display: flex;
  height: 100vh;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;

  &-text {
    color: #fff;
    font-size: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    z-index: 999;
    position: absolute;
    width: 80%;

    span {
      font-size: 50px;
    }

    .small {
      font-size: 20px;

      pre {
        width: 400px;
      }

      div {
        margin: 12px 0;
        line-height: 2;
      }
    }
  }
}
</style>
